<?php

namespace App\WechatHandlers;

use App\Models\NormalReply;
use App\Services\WechatCustomService;
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;

class EventMessageHandler implements EventHandlerInterface
{
    public function handle($payload = null)
    {
        switch ($payload['Event']) {
            case 'subscribe':    // 关注
                $reply = NormalReply::query()
                    ->where('event_type', NormalReply::EVENT_SUBSCRIBE)
                    ->first();
                if ($reply) {
                    WechatCustomService::send($reply, $payload['FromUserName']);
                }
                break;
            case 'unsubscribe':  // 取消关注
                break;
            case 'scan':         // 已关注用户扫码
                break;
            case 'location':     // 上报地理位置
                break;
            case 'click':        // 点击自定义菜单获取消息
                break;
            case 'view':         // 点击自定义菜单跳转链接
                break;
        }
    }
}